<html lang="zh-CN">
<header>
    <h1>ICP备案查询</h1>
</header>
<main>

    <input type="text" id="domain" placeholder="请输入域名地址">


    <p>请输入域名地址，例如：www.example.com</p>

    <button onclick="checkICP()">查询</button>

    <div class="result" id="result"></div>
</main>
<script>
    function checkICP() {
        const domain = document.getElementById('domain').value;

        if (!domain) {
            alert('请输入域名地址');
            return;
        }

        const url = `https://papi.v-box.cn/api/app/open-api/icp?url=${domain}`;

        fetch(url)
            .then(response => response.json())
            .then(data => {
                const resultDiv = document.getElementById('result');
                if (data.code === 200) {
                    resultDiv.innerHTML = `
                            <p><strong>域名：</strong> ${data.data.domain}</p>
                            <p><strong>ICP备案号：</strong> ${data.data.icp}</p>
                            <p><strong>公司名称：</strong> ${data.data.company}</p>
                            <p><strong>网站名称：</strong> ${data.data.websiteName}</p>
                        `;
                } else {
                    resultDiv.innerHTML = `<p>查询失败: ${data.message}</p>`;
                }
            })
            .catch(error => {
                const resultDiv = document.getElementById('result');
                resultDiv.innerHTML = `<p>查询出错: ${error}</p>`;
            });
    }
</script>
</html>